<!DOCTYPE html>
<html lang="zh">
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta name="description" content=""/>

    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:image:src" content="https://avatars1.githubusercontent.com/u/64068543?s=400&amp;v=4"/>
    <meta name="twitter:title" content="labml.ai 带注释的 PyTorch 版论文实现"/>
    <meta name="twitter:description" content=""/>
    <meta name="twitter:site" content="@labmlai"/>
    <meta name="twitter:creator" content="@labmlai"/>

    <meta property="og:url" content="https://nn.labml.ai/index.html"/>
    <meta property="og:title" content="labml.ai 带注释的 PyTorch 版论文实现"/>
    <meta property="og:image" content="https://avatars1.githubusercontent.com/u/64068543?s=400&amp;v=4"/>
    <meta property="og:site_name" content="labml.ai 带注释的 PyTorch 版论文实现"/>
    <meta property="og:type" content="object"/>
    <meta property="og:title" content="labml.ai 带注释的 PyTorch 版论文实现"/>
    <meta property="og:description" content=""/>

    <title>labml.ai 带注释的 PyTorch 版论文实现</title>
    <link rel="shortcut icon" href="/icon.png"/>
    <link rel="stylesheet" href="./pylit.css?v=1">
    <link rel="canonical" href="https://nn.labml.ai/index.html"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.css" integrity="sha384-zTROYFVGOfTw7JV7KUu8udsvW2fx4lWOsCEDqhBreBwlHI4ioVRtmIvEThzJHGET" crossorigin="anonymous">

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-4V3HC8HBLH"></script>
    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());

        gtag('config', 'G-4V3HC8HBLH');
    </script>
</head>
<body>
<div id='container'>
    <div id="background"></div>
    <div class='section'>
        <div class='docs'>
            <p>
                <a class="parent" href="/">home</a>
            </p>
            <p>
                <a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations" target="_blank">
                    <img alt="Github"
                         src="https://img.shields.io/github/stars/labmlai/annotated_deep_learning_paper_implementations?style=social"
                         style="max-width:100%;"/></a>
                <a href="https://twitter.com/labmlai" rel="nofollow" target="_blank">
                    <img alt="Twitter"
                         src="https://img.shields.io/twitter/follow/labmlai?style=social"
                         style="max-width:100%;"/></a>
            </p>
            <p>
                <a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations/tree/master/labml_nn/__init__.py" target="_blank">
                    View code on Github</a>
            </p>
        </div>
    </div>
    <div class='section' id='section-0'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-0'>#</a>
            </div>
            <h1><a href="index.html">labml.ai 带注释的 PyTorch 版论文实现</a></h1>
<p>这是一个用 PyTorch 实现各种神经网络和相关算法的集合。每个算法的<a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations">代码实现</a>都有详细的解释说明，且在<a href="index.html">网站</a>上与代码逐行对应。我们相信，这些内容将帮助您更好地理解这些算法。</p>
<p><img alt="Screenshot" src="dqn-light.png"></p>
<p>我们正在积极维护这个仓库并添加新的代码实现。<a href="https://twitter.com/labmlai"><img alt="Twitter" src="https://img.shields.io/twitter/follow/labmlai?style=social"></a>以获取更新。</p>
<h2>翻译</h2>
<h3><strong><a href="https://nn.labml.ai">英语（原版）</a></strong></h3>
</a><h3><strong><a href="https://nn.labml.ai/zh/">中文（翻译）</strong></h3>
</a><h3><strong><a href="https://nn.labml.ai/ja/">日语（翻译）</strong></h3>
<h2>论文实现</h2>
<h4>✨ <a href="transformers/index.html">Transformers</a></h4>
<ul><li><a href="transformers/mha.html">多头注意力</a></li>
<li><a href="transformers/models.html">Transformer 构建模块</a></li>
<li><a href="transformers/xl/index.html">Transformer XL</a></li>
<li><a href="transformers/xl/relative_mha.html">相对多头注意力</a></li>
<li><a href="transformers/rope/index.html">旋转式位置编码 (ROPE)</a></li>
<li><a href="transformers/alibi/index.html">线性偏差注意力 (AliBI)</a></li>
<li><a href="transformers/retro/index.html">RETRO</a></li>
<li><a href="transformers/compressive/index.html">压缩 Transformer</a></li>
<li><a href="transformers/gpt/index.html">GPT 架构</a></li>
<li><a href="transformers/glu_variants/simple.html">GLU 变体</a></li>
<li><a href="transformers/knn/index.html">kNN-LM：通过记忆实现泛化</a></li>
<li><a href="transformers/feedback/index.html">自反馈 Transformer</a></li>
<li><a href="transformers/switch/index.html">Switch Transformer</a></li>
<li><a href="transformers/fast_weights/index.html">快速权重 Transformer</a></li>
<li><a href="transformers/fnet/index.html">FNet</a></li>
<li><a href="transformers/aft/index.html">无注意力 Transformer</a></li>
<li><a href="transformers/mlm/index.html">掩码语言模型</a></li>
<li><a href="transformers/mlp_mixer/index.html">MLP-Mixer：一种用于视觉的全 MLP 架构</a></li>
<li><a href="transformers/gmlp/index.html">门控多层感知器 (gMLP)</a></li>
<li><a href="transformers/vit/index.html">视觉 Transformer (ViT)</a></li>
<li><a href="transformers/primer_ez/index.html">Primer</a></li>
<li><a href="transformers/hour_glass/index.html">沙漏网络</a></li></ul>
<h4>✨ <a href="neox/index.html">Eleuther GPT-neox</a></h4>
<ul><li><a href="neox/samples/generate.html">在一块 48GB GPU 上生成</a></li> 
<li><a href="neox/samples/finetune.html">在两块 48GB GPU 上微调</a></li>
<li><a href="neox/utils/llm_int8.html">llm.int8 ()</a></li></ul>
<h4>✨ <a href="diffusion/index.html">扩散模型</a></h4>
<ul><li><a href="diffusion/ddpm/index.html">去噪扩散概率模型 (DDPM)</a></li>
<li><a href="diffusion/stable_diffusion/sampler/ddim.html">去噪扩散隐式模型 (DDIM)</a></li>
<li><a href="diffusion/stable_diffusion/latent_diffusion.html">潜在扩散模型</a></li>
<li><a href="diffusion/stable_diffusion/index.html">Stable Diffusion</a></li></ul>
<h4>✨ <a href="gan/index.html">生成对抗网络</a></h4>
<ul><li><a href="gan/original/index.html">原始 GAN</a></li>
<li><a href="gan/dcgan/index.html">使用深度卷积网络的 GAN</a></li>
<li><a href="gan/cycle_gan/index.html">循环 GAN</a></li>
<li><a href="gan/wasserstein/index.html">Wasserstein GAN</a></li>
<li><a href="gan/wasserstein/gradient_penalty/index.html">具有梯度惩罚的 Wasserstein GAN</a></li>
<li><a href="gan/stylegan/index.html">StyleGan 2</a></li></ul>
<h4>✨ <a href="recurrent_highway_networks/index.html">循环高速路网络</a></h4>
<h4>✨ <a href="lstm/index.html">LSTM</a></h4>
<h4>✨ <a href="hypernetworks/hyper_lstm.html">超网络-HyperLSTM</a></h4>
<h4>✨ <a href="resnet/index.html">ResNet</a></h4>
<h4>✨ <a href="conv_mixer/index.html">ConvMixer</a></h4>
<h4>✨ <a href="capsule_networks/index.html">胶囊网络</a></h4>
<h4>✨ <a href="unet/index.html">U-Net</a></h4>
<h4>✨ <a href="sketch_rnn/index.html">Sketch RNN</a></h4>
<h4>✨ 图神经网络</h4>
<ul><li><a href="graphs/gat/index.html">图注意力网络 (GAT)</a></li>
<li><a href="graphs/gatv2/index.html">图注意力网络 v2 (GATv2)</a></li></ul>
<h4>✨ <a href="rl/index.html">强化学习</a></h4>
<ul><li><a href="rl/ppo/index.html">近端策略优化</a>与<a href="rl/ppo/gae.html">广义优势估计</a></li>
<li>具有<a href="rl/dqn/model.html">对抗网络</a>、<a href="rl/dqn/replay_buffer.html">优先回放 </a>和双 Q 网络的<a href="rl/dqn/index.html">深度 Q 网络</a></li></ul>
<h4>✨ <a href="cfr/index.html">虚拟遗憾最小化（CFR）</a></h4>
<p>使用 CFR 解决诸如扑克等不完全信息游戏</p>
<ul><li><a href="cfr/kuhn/index.html">库恩扑克</a></li></ul>
<h4>✨ <a href="optimizers/index.html">优化器</a></h4>
<ul><li><a href="optimizers/adam.html">Adam 优化器</a></li>
<li><a href="optimizers/amsgrad.html">AMSGrad 优化器</a></li>
<li><a href="optimizers/adam_warmup.html">具有预热的 Adam 优化器</a></li>
<li><a href="optimizers/noam.html">Noam 优化器</a></li>
<li><a href="optimizers/radam.html">RAdam 优化器</a></li>
<li><a href="optimizers/ada_belief.html">AdaBelief 优化器</a></li>
<li><a href="optimizers/sophia.html">Sophia-G Optimizer</a></li></ul>
<h4>✨ <a href="normalization/index.html">归一化层</a></h4>
<ul><li><a href="normalization/batch_norm/index.html">批量归一化</a></li>
<li><a href="normalization/layer_norm/index.html">层归一化</a></li>
<li><a href="normalization/instance_norm/index.html">实例归一化</a></li>
<li><a href="normalization/group_norm/index.html">组归一化</a></li>
<li><a href="normalization/weight_standardization/index.html">权重标准化</a></li>
<li><a href="normalization/batch_channel_norm/index.html">批-通道归一化</a></li>
<li><a href="normalization/deep_norm/index.html">DeepNorm</a></li></ul>
<h4>✨ <a href="distillation/index.html">蒸馏</a></h4>
<h4>✨ <a href="adaptive_computation/index.html">自适应计算</a></h4>
<ul><li><a href="adaptive_computation/ponder_net/index.html">PonderNet</a></li></ul>
<h4>✨ <a href="uncertainty/index.html">不确定性</a></h4>
<ul><li><a href="uncertainty/evidence/index.html">用于量化分类不确定性的证据深度学习</a></li></ul>
<h4>✨ <a href="activations/index.html">激活函数</a></h4>
<ul><li><a href="activations/fta/index.html">模糊平铺激活函数</a></li></ul>
<h4>✨ <a href="sampling/index.html">语言模型采样技术</a></h4>
<ul><li><a href="sampling/greedy.html">贪婪采样</a></li>
<li><a href="sampling/temperature.html">温度采样</a></li>
<li><a href="sampling/top_k.html">Top-K 采样</a></li>
<li><a href="sampling/nucleus.html">核采样</a></li></ul>
<h4>✨ <a href="scaling/index.html">可扩展训练/推理</a></h4>
<ul><li><a href="scaling/zero3/index.html">ZeRO-3 内存优化</a></li></ul>
<h3>安装</h3>
<pre  class="highlight lang-bash"><code><span></span>pip<span class="w"> </span>install<span class="w"> </span>labml-nn</code></pre>

        </div>
        <div class='code'>
            <div class="highlight"><pre></pre></div>
        </div>
    </div>
    <div class='footer'>
        <a href="https://labml.ai">labml.ai</a>
    </div>
</div>
<script src=./interactive.js?v=1"></script>
<script>
    function handleImages() {
        var images = document.querySelectorAll('p>img')

        for (var i = 0; i < images.length; ++i) {
            handleImage(images[i])
        }
    }

    function handleImage(img) {
        img.parentElement.style.textAlign = 'center'

        var modal = document.createElement('div')
        modal.id = 'modal'

        var modalContent = document.createElement('div')
        modal.appendChild(modalContent)

        var modalImage = document.createElement('img')
        modalContent.appendChild(modalImage)

        var span = document.createElement('span')
        span.classList.add('close')
        span.textContent = 'x'
        modal.appendChild(span)

        img.onclick = function () {
            console.log('clicked')
            document.body.appendChild(modal)
            modalImage.src = img.src
        }

        span.onclick = function () {
            document.body.removeChild(modal)
        }
    }

    handleImages()
</script>
</body>
</html>